﻿using UnityEngine;
using System.Collections;

public class ButtonBack : MonoBehaviour {
    [SerializeField]
    private AudioClip soundClip;
	GameManager manager;
	void Start () {
		manager=GameManager.getInstance();
	}
	private void BackingScence(){
        if (manager.Sound)
        { PlaySound(); }
		manager.IsShow=false;
		switch(Application.loadedLevel){
		case 1: Application.Quit();break;
		case 2: Application.Quit();break;
		case 3: Application.LoadLevel(2);break;
		}
	}
	void Update(){
		if(Input.GetKeyDown(KeyCode.Escape)){
			BackingScence();
		}
	}
    private void Setting()
    {
        if (manager.Sound)
        { PlaySound(); }
    }
    void PlaySound()
	{	if(soundClip==null){return;}
        audio.clip = soundClip;
        audio.Play();
    }
}
